1."==" , "=" & ">="
== 意为判断前后是否相等,如下例所示:
>>> 10 == 8
False
= 意为赋值,如:

>>> a = 10
>>> print(a)
10
>= 大于等于号,如:
age = 20
>>> Old_enough = age >= 17
>>> Old_enough
True
2.Logical Operators (武老大高一的时候讲过,不会的要被查水表了)
(1) And: 只有在input都为"True"的条件下output才为"True"
(2) Or: 只要input中有一个为"True"那么output就为"True"
(3)Not: "False"变"True","True"变"False"

3.Truth Tables
a
b
a or b
F
F
F
F
T
T
T
F
T
T
T
T

a
b
a and b
False
False
False
False
True
False
True
False
False
True
True
True

a
not a
F
T
T
F
4. Break
The break statement is used to immediately leave the body of its loop. The next statement to be executed is the first one after the body:
for i in [12, 16, 17, 24, 29]:
    if i % 2 == 1:
        break
    print(i)
print(done)
5.Continue
This is a control flow statement that causes the program to immediately skip the processing of the rest of the body of the loop, for the current iteration. But the loop still carries on running for its remaining iterations:
for i in [12, 16, 17, 24, 29, 30]:
    if i % 2 == 1:
        continue
    print(i)
print("done")
 
6.Return
跳出函数,把后面作为返回值,只能用于函数中。

7.Comments and Notations are very important! (To remind yourself)

8.Composition
即函数调用函数,在之前用五个五角星组一个大五角星一题中大家已经练习过了。

9.Recursion
即函数调用自己,递归,如:
def Factorial(n):
    if n == 0 or n == 1:
        return 1
    else:
        return(n * Factorial(n - 1))
 
print(Factorial(6))

Finally, the homework is to write a program to represent the steps of the Hanoi Tower.
-different sides of disks on the first rod
-there are three rods in total
-only one disk can be moved at a time
-each move consists of taking the upper disk from one of thstacks and placing it on top of another stack
-no disk may be placed on top of a smaller disk

Hanoi(a, c, n)
Hanoi(a, c, 1)
Hanoi(a, c, n-1)
Leave the calculations to your computer
show each of the steps!